package com.huikaka.controller;

import com.huikaka.entity.Award;
import com.huikaka.entity.Result;
import com.huikaka.service.AwardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/award")
public class AwardController {
    @Autowired
    private AwardService awardService;

//    通过邀请码查找用户所有的历史奖励
    @RequestMapping("/findAllAwardInfoByInviteCode")
    public Result findAllAwardInfoByInviteCode(@RequestParam String inviteCode){
        Result result = new Result();
        try{
            List<Award> awardList = awardService.findAllAwardInfoByInviteCode(inviteCode);
            if(awardList!=null){
                result.setCode(0);
                result.setMessage("成功");
                result.setData(awardList);
                return result;
            }
            result.setCode(1);
            result.setMessage("失败");
        }catch (Exception e){

        }
        return result;
    }

}
